﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit.MEP.Opening
{
	public class OpeningFillRegionFilter : ISelectionFilter
	{
		public OpeningFillRegionFilter(double dMinSize)
		{
			this.m_dMinSize = dMinSize;
		}

		public bool AllowElement(Element elem)
		{
			if (elem is FilledRegion)
			{
				FilledRegionType filledRegionType = (FilledRegionType)elem.Document.GetElementById(elem.GetTypeId());
				if (filledRegionType != null && filledRegionType.Name == "HYOpening2DFilledRegionType")
				{
					return CmdOpeningDim.IsOpening2DRegionSizeStatify(elem, this.m_dMinSize);
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}

		private double m_dMinSize = 300.0;
	}
}
